package org.bits.ui;

import java.awt.Component;

import org.bits.common.model.ItemTableModel;
import org.bits.common.ui.ItemListEditPanel;
import org.bits.data.Product;
import org.bits.model.DataAccessModel;
import org.bits.ui.model.ProductsTableModel;

public class ProductsView
{
    private ProductsTableModel productsModel;
    private ItemListEditPanel<Product> productsPanel;

    public ProductsView()
    {
        productsModel = new ProductsTableModel();
        productsPanel = createProductsView( productsModel );
    }

    private ItemListEditPanel<Product> createProductsView(
        ItemTableModel<Product> model )
    {
        ItemListEditPanel<Product> panel = new ItemListEditPanel<Product>(
            model, "Product" );

        return panel;
    }

    public void setDataModel( DataAccessModel model )
    {
        productsModel.setItems( model.getProducts() );
    }

    public Component getView()
    {
        return productsPanel.getView();
    }
}
